package com.simon.jkxj.ui.diet;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import com.simon.jkxj.R;

public class BloodPressureAddActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_blood_pressure_add);
        ImageView btnBack = findViewById(R.id.btn_back);
        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        Button btnSave = findViewById(R.id.btn_save);
        btnSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText etSbp = findViewById(R.id.et_sbp);
                EditText etDbp = findViewById(R.id.et_dbp);
                EditText etHr = findViewById(R.id.et_hr);
                int sbp = 0, dbp = 0, hr = 0;
                try { sbp = Integer.parseInt(etSbp.getText().toString()); } catch (Exception ignored) {}
                try { dbp = Integer.parseInt(etDbp.getText().toString()); } catch (Exception ignored) {}
                try { hr = Integer.parseInt(etHr.getText().toString()); } catch (Exception ignored) {}
                Intent data = new Intent();
                data.putExtra("sbp", sbp);
                data.putExtra("dbp", dbp);
                data.putExtra("hr", hr);
                data.putExtra("bp_time", System.currentTimeMillis());
                setResult(RESULT_OK, data);
                finish();
            }
        });
    }
} 